# import pymysql
#
# db = pymysql.connect(
#     host = 'localhost', # 数据库的连接地址
#     user = 'root',
#     password = '',
#     database = 'test',
#     port = 3306,
#     charset = 'utf8'
# )
#
# cursor = db.cursor()
# sql = 'DROP TABLE IF EXISTS person'
# cursor.execute(sql)
# db.commit()
#
# sql = 'create table person(username varchar(20),age int,sex char(4),high int)'
# cursor.execute(sql)
# db.commit()
#
# data = ("('张三',15,'男',168),"
#         "('李四',15,'男',168),"
#         "('王五',15,'男',168),"
#         "('赵六',15,'男',168),"
#         "('孙琪',15,'男',168),"
#         "('钱八',15,'男',168),"
#         "('吴九',15,'男',168),"
#         "('周十',15,'男',168),"
#         "('可达',15,'男',168),"
#         "('是否',15,'男',168)")
# print(data)
#
# sql = f'insert into person values {data}'
# cursor.execute(sql)
# db.commit()
#
# cursor.close()
# db.close()





import pymysql

db = pymysql.connect(
    host = 'localhost', # 数据库的连接地址
    user = 'root',
    password = '',
    database = 'test',
    port = 3306,
    charset = 'utf8'
)

cursor = db.cursor()
sql = 'DROP TABLE IF EXISTS person'
cursor.execute(sql)
db.commit()

sql = 'create table person(username varchar(20),age int,sex char(4),high int)'
cursor.execute(sql)
db.commit()

data = [('张',15,'男',168),
        ('李四',15,'男',168),
        ('王五',15,'男',168),
        ('赵六',15,'男',168),
        ('孙琪',15,'男',168),
        ('钱八',15,'男',168),
        ('吴九',15,'男',168),
        ('周十',15,'男',168),
        ('可达',15,'男',168),
        ('是否',15,'男',168)]
print(data)

for i in data:
    sql = f'insert into person values {i}'
    cursor.execute(sql)
    db.commit()

cursor.close()
db.close()